<?php
/*
我的返券
*/
include('../conn.php');
// 需传参数 
$userid = $_REQUEST['userid'];
$type = $_REQUEST['type'];
$shopid = $_REQUEST['shopid'];
// 需传参数 end

// 状态
$is_use = 0; // 未使用
$shopid0 = 0;
// 状态 end

// 初始化
$shopfanquan = array();
$fanquan = array();
// 初始化 end

if ($userid != '' && in_array($type,array(0 ,1)) && $shopid != '' ) {
	// 商家返券 
	$query = mysql_query("select fanquanid,price,addtime from myfanquan where userid=".$userid." and type=".$type." and shopid=".$shopid." and is_use=".$is_use."");
	while ($row = mysql_fetch_assoc($query)) {
		$shopfanquan[] = $row;
	}
	// 商家返券 end

	// 平台返券 
	$query = mysql_query("select fanquanid,price,addtime from myfanquan where userid=".$userid." and type=".$type." and shopid=".$shopid0." and is_use=".$is_use."");
	while ($row = mysql_fetch_assoc($query)) {
		$fanquan[] = $row;
	}
	// 平台返券 end
	$arr = array('code' => 200, 'msg' => '查询成功', 'shopfanquan' => $shopfanquan, 'fanquan' => $fanquan);	
}else{
	$arr = array('code' => 400, 'msg' => 'userid或type(0或1)或shopid不存在' );
}
echo json_encode($arr);